import java.util.Vector;

class GlobalAnalysis{
    Vector<ObjectAnalysis> v_object_analysis;
    float global_degree;
    protected Vector<FuzzySetGA> v_sets; //fuzzy set that represent the different normality intervals.
    protected Vector<Float> v_membership_intervals; //mebership values to the normality intervals


    public GlobalAnalysis(){
	v_object_analysis = new Vector();
	global_degree = 1;
	//creating v_sets
	v_sets = new Vector();
	v_sets.addElement(new FuzzySetGA("absolutely abnormal", new Float(0), new Float(0), new Float(0.1), new Float(0.2)));
	v_sets.addElement(new FuzzySetGA("possibly abnormal", new Float(0.1), new Float(0.2), new Float(0.3), new Float(0.4)));
	v_sets.addElement(new FuzzySetGA("suspicius", new Float(0.3), new Float(0.4), new Float(0.5), new Float(0.6)));
	v_sets.addElement(new FuzzySetGA("possibly normal", new Float(0.5), new Float(0.6), new Float(0.7), new Float(0.8)));
	v_sets.addElement(new FuzzySetGA("absolutely normal", new Float(0.7), new Float(0.8), new Float(1), new Float(1)));
	v_membership_intervals = new Vector();
    }

    public void addObjectAnalysis(ObjectAnalysis oa){
	this.v_object_analysis.addElement(oa);
    }
    public float getMembershipIntervalAt(int pos){
	return this.v_membership_intervals.elementAt(pos);
    }
    public float getGlobalDegree(){return this.global_degree;}

    public void calculateGlobalDegree(){
	//calculating minimun OWA value
	float minimum_owa = 1;
	for(int i=0; i < v_object_analysis.size(); i++){
	    ObjectAnalysis oa = v_object_analysis.elementAt(i);
	    if(minimum_owa > oa.getGlobalDegree())
		minimum_owa = oa.getGlobalDegree();
	}//end for

	this.global_degree = minimum_owa;
	//determining the membership value of the minimum owa to the normality intervals
	for(int i=0; i < this.v_sets.size(); i ++){
	    FuzzySetGA set = v_sets.elementAt(i);
	    this.v_membership_intervals.addElement(set.membershipValue(this.global_degree));	    
	}//end for
    }//end method
    
}//end GlobalAnalysis
